<?
		get_header();
?>

<td>
    <div id="content">
		<?
				while (have_posts()) {
					the_post();
					if (has_post_thumbnail($post_id)) {
						$default = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large');
						$destaque = $default[0];
					}

					$args = array(
						'order' => 'ASC',
						'orderby' => 'menu_order',
						'post_type' => 'attachment',
						'numberposts' => -1,
						'post_status' => null,
						'post_parent' => $post->ID
					);

					$attachments = get_posts($args);

					if ($attachments) {
						foreach ($attachments as $attachment) {
							$img[] = wp_get_attachment_image_src($attachment->ID, 'large');
						}
					}

					if (!$destaque) {
						$destaque = $img[0][0];
					}
					
					//$custom_fields = get_post_custom();
					//print_r($custom_fields);
					
					?>
					<div id="single">
						<div class="destaque right">
							<div class="iProduto" style="background: url('<?= get_bloginfo("template_url"); ?>/img.php?src=<?= $destaque; ?>&w=380&h=320&zc=1') no-repeat;" url="<?= $destaque; ?>"></div>
							<div class="imagens">
								<?
								if (count($img) > 1) {
									$x = 0;
									foreach ($img as $mini) {
										if ($x == 6) {
											break;
										}
										echo '<div class="iProdutoMini left" style="background: url(' . get_bloginfo("template_url") . '/img.php?src=' . $mini[0] . '&w=50&h=50&zc=1) no-repeat;" url="' . $mini[0] . '"></div>';
										$x++;
									}
								}
								?>
							</div>
						</div>
						<div class="barraSocial right">
							<ul class="social">
								<li>
									<div id="fb-root" class=" fb_reset"></div>
									<span style="height: 65px; width: 55px;">
										<iframe src="//www.facebook.com/plugins/like.php?href=<?= urlencode(get_permalink()); ?>&amp;width=55&amp;height=65&amp;colorscheme=light&amp;layout=box_count&amp;action=like&amp;show_faces=false&amp;send=true&amp;appId=156924041123002" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:55px; height:65px;" allowTransparency="true"></iframe>
									</span>
								</li>
								<li>
									<iframe allowtransparency="true" frameborder="0" scrolling="no" src="http://platform.twitter.com/widgets/tweet_button.1375828408.html#_=1376870137145&amp;count=vertical&amp;id=twitter-widget-0&amp;lang=en&amp;original_referer=<?= urlencode(get_permalink()); ?>&amp;size=m&amp;text=<?= urlencode(get_the_title()); ?>&amp;url=<?= urlencode(get_permalink()); ?>" class="twitter-share-button twitter-count-vertical" title="Twitter Tweet Button" data-twttr-rendered="true" style="width: 56px; height: 62px;"></iframe>
									<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
								</li>
							</ul>
						</div>

						<div>
							<div class="boxProduto"  alt="<?= strtolower(get_the_title()); ?>" title="<?= strtolower(get_the_title()); ?>">
								<div class="stProduto">
									<?= get_the_title(); ?>
								</div>
								<div class="spProduto">
									<span>
										Pre&ccedil;o:
									</span>
									<br />
									R$ <?= get_post_meta($post->ID, 'meta_box_preco', true); ?>
								</div>
								<div class="scProduto">
									<?
									//$custom_fields = get_post_custom(get_the_ID());
									//print_r($custom_fields);

									$post_id = get_the_ID();
									$labels = get_labels();
									foreach ($labels as $label) {
										$filtros = get_post_filter($post_id, $label->id_filter);
										if ($filtros) {
											echo "<span><b>" . $label->label . ":</b></span><br />";
											echo "<select id='filtro' name='$label->id_filter'>";
											echo "<option value=''>- Selecione uma opção</option>";
											foreach ($filtros as $filtro) {
												echo "<option value='$filtro->id'>- " . $filtro->label . "</option>";
											}
											echo "</select><br /><br />";
										}
									}
									?>
								</div>
								<div class="scProduto">
									<a class="linked" href="javascript:void(0);" pid="<?= $post->ID; ?>">
										<img src="<?= get_bloginfo('template_url') . '/img/button-comprar.png' ?>" border="0">
									</a>
								</div>
								<div class="sdProduto">
									<? the_content(); ?>
								</div>
							</div>
						</div>
						<div class="cls"></div>
					</div>
					<?
				}
		?>
	</div> <!--  #content -->
</td>
<? get_footer(); ?>